package com.imooc.controller;


import com.imooc.pojo.vo.TbSampleVO;
import com.imooc.service.TbSampleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author: ZhaoYiChen
 * @create: 2020-09-10 09:45
 **/

/**
 * @Controller : 适用于页面跳转
 * @RestController : 适用于json数据传输
 */
@ApiIgnore //隐藏api：使用@ApiIgnore注解后，可以隐藏 swagger2 api接口
@RestController
public class HelloController {
    @Autowired
    private TbSampleService tbSampleService;
    final static Logger logger= LoggerFactory.getLogger(HelloController.class);

    @GetMapping("/hello2")
    public Object hello2() {
        return "Hello world~";
    }

    @RequestMapping("/hello")
    public String hello(String name) {

        logger.debug("debug: hello~");
        logger.info("info: hello~");
        logger.warn("warn: hello~");
        logger.error("error: hello~");

        return "Hello world~" + name;
    }

    @RequestMapping("/numberTest")
    @ResponseBody
    public List<TbSampleVO> numberTest(String code) {
        List<TbSampleVO> tbSampleVOS = tbSampleService.queryTbSample(code);
        return tbSampleVOS;
    }
}
